﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Delonix_Regia_Hotel_Management_System.Class;

namespace Delonix_Regia_Hotel_Management_System
{
    public partial class Staff_Registeration : Form
    {
        public Staff_Registeration()
        {
            InitializeComponent();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (LogInClass.position == "Administrator")
            {
                Main__Management_and_Administrator_ mainA = new Main__Management_and_Administrator_();
                this.Hide();
                mainA.Show();
            }
            else
            {
                Main__Receptionist_ mainR = new Main__Receptionist_();
                this.Hide();
                mainR.Show();
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Form1 F = new Form1();
            this.Hide();
            F.Show(); 
        }

        private void Staff_Registeration_Load(object sender, EventArgs e)
        {

        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            string staffId = tbxStaffID.Text;
            string staffName = tbxStaffName.Text;
            DateTime dob = Convert.ToDateTime(comboBoxDD.Text + "/" + comboBoxMM.Text + "/" + comboBoxYY.Text);
            string bankAccount = tbxBankAcc.Text;
            string homeAddress = tbxAddress.Text;
            int phoneNum = Convert.ToInt32(tbxContactNo.Text);
            string position = Convert.ToString(comboBoxPosition.Text);
            string staffPassword = tbxPassword.Text;

            Staff g = new Staff(staffId, staffName, dob, bankAccount, homeAddress, phoneNum, position, staffPassword);

            if (DBManager.CreateStaff(g) == 1)
            {
                MessageBox.Show("Staff successfully created!");
                Form1 Login = new Form1();
                this.Hide();
                Login.Show();
            }

        }

        
    }
}
